<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="字典管理" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
    <div class="col-sm-12 search-collapse">
    <@f.form id="type-form">
        <div class="select-list">
            <ul>
                <li>
                    ${i18n("应用编码")}：<input type="text" class="form-control" name="appNo"/>
                </li>
                <li>
                    ${i18n("字典名称")}：<input type="text"  class="form-control" name="dictName"/>
                </li>
                <li>
                    ${i18n("字典类型")}：<input type="text" class="form-control" name="dictType"/>
                </li>
                <li>
                    ${i18n("字典状态")}：
                    <@f.select name="status" blankValue="" blankLabel="所有" dictType="sys_normal_disable" />
                </li>
                <li>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;${i18n("查询")}</a>
                    <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;${i18n("重置")}</a>
                </li>
            </ul>
        </div>
    </@f.form>
    </div>
    <@table id="bootstrap-table">
        <@shiro.hasPermission name="sys:dict:add">
            <a class="btn btn-success" onclick="opt.operate.add()"><i class="fa fa-plus"></i>&nbsp;${i18n("新增")}</a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:edit">
            <a class="btn btn-primary single disabled" onclick="opt.operate.edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;${i18n("修改")}</a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:del">
            <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()"><i class="fa fa-remove"></i> ${i18n("删除")}</a>
        </@shiro.hasPermission>
        <@shiro.hasPermission name="sys:dict:clear">
            <a class="btn btn-danger" onclick="clearRedis()"><i class="fa fa-refresh"></i>&nbsp;${i18n("刷新缓存")}</a>
        </@shiro.hasPermission>
    </@table>
    </div>
</div>
<@footer>
<script>
    var editFlag = "${permission.hasPermi('sys:dict:edit')}";
    var listFlag = "${permission.hasPermi('sys:dict:add')}";
    var delFlag = "${permission.hasPermi('sys:dict:del')}";
    var statusDatas = ${dict.getDictListJson('sys_normal_disable')};
    var isSysDatas = ${dict.getDictListJson('sys_yes_no')};
    var visible = ${permission.isPermitteds("sys:dict:edit,sys:dict:del,sys:dict:add")?string('true', 'false')};
    var prefix = baseURL + 'sys/dict';

    var _vm = new Vue({
        el:'#_app',
        data:{
        },
        methods:{
            detail:function (dictId) {
                var url = prefix + '/detail/' + dictId;
                opt.modal.openTab("${i18n("字典数据")}", url);
                return;
            }
        },
        updated : function(){
        },
        mounted:function () {
            /*初始表格对象*/
            var options = {
                url: prefix + "/list",
                addUrl: prefix + "/add",
                editUrl: prefix + "/edit/{id}",
                delUrl: prefix + "/del",
                sortName: "id",
                uniqueId: "id",
                height: function(){ return $(window).height() - 100},
                pageSize: 12,
                pageList: [12, 24, 36],
                modalName: "${i18n("字典")}",
                columns: [
                    {title: "${i18n("序号")}",width:15,align:"center", formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                    }},
                    /*{checkbox: true},*/
                    {field: 'id',title: '${i18n("字典主键")}', sortable: true},
                    {field: 'appNo', title: '${i18n("应用编码")}'},
                    {field: 'appName', title: '${i18n("应用名称")}', visible: false},
                    {field: 'dictName', title: '${i18n("字典名称")}'},
                    {field: 'dictType', title: '${i18n("字典类型")}', formatter: function(value, row, index) {
                            return '<a class="tb-view" href="javascript:void(0)" onclick="_vm.detail(\'' + row.id + '\')">' + value + '</a>';
                    }},
                    {field: 'status', title: $.i18n.prop("${i18n("状态")}"), align: 'center', formatter: function(value, row, index) {
                            return opt.common.selectDictLabel(statusDatas, value);
                    }},
                    {field: 'remark', title: $.i18n.text("备注"),formatter: function(value, row, index) {
                            return opt.common.tooltip(value,8);
                    }},
                    {field: 'createTime', title: $.i18n.text("创建时间"), sortable: true},
                    {field: 'isSys', title: '${i18n("系统内置")}', formatter: function(value, row, index) {
                            return opt.common.selectDictLabel(isSysDatas, value);
                    }},
                    {title:"${i18n("操作")}", align: 'center',visible:visible, formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opt.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> ${i18n("编辑")}</a> ');
                            actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="_vm.detail(\'' + row.id + '\')"><i class="fa fa-list-ul"></i> ${i18n("列表")}</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> ${i18n("删除")}</a>');
                            return actions.join('');
                    }}]
            };
            $.table.init(options);
        }
    })

    function clearRedis() {
        opt.operate.get(prefix + "/clearDict")
    }
</script>
</@footer>
</@pageTheme>